// Filename: views/person/viewPersons
define([
  'jquery',
  'underscore',
  'backbone',
  // Pull in the Collection module from above
  'collections/users',
  'text!../../../templates/listPersonTemplate.html'
], function($, _, Backbone, UserCollection, listPersonTemplate){
	var PersonListView = Backbone.View.extend({
			el: '.page',
			render: function(){
				var that = this;
				var users = new UserCollection();				
				users.fetch({
					success: function() {
						//console.log(users.models[0].attributes);
						var template = _.template(listPersonTemplate, {users: users.models});
						that.$el.html(template);
					}
				});
			}
		});
  // Returning instantiated views can be quite useful for having "state"
  return PersonListView;
});